#!/usr/bin/env python
"""
快速调试景点数据
"""
import os
import sys
import django

# 设置Django环境
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'travel_plan.settings')
django.setup()

from apps.attractions.models import Attraction

def quick_debug():
    print("=" * 60)
    print("快速调试景点数据")
    print("=" * 60)

    # 1. 检查景点总数
    total = Attraction.objects.count()
    print(f"总景点数: {total}")

    # 2. 检查有图片的景点
    with_images = Attraction.objects.filter(
        amap_image_urls__isnull=False
    ).exclude(amap_image_urls=[]).count()
    print(f"有图片的景点数: {with_images}")

    no_images = total - with_images
    print(f"没有图片的景点数: {no_images}")

    # 3. 检查前2个景点
    print("\n前2个景点详情:")
    for i, attr in enumerate(Attraction.objects.all()[:2], 1):
        print(f"\n景点 {i}: {attr.name}")
        print(f"  POI ID: {attr.amap_poi_id}")
        print(f"  图片数量: {len(attr.amap_image_urls) if attr.amap_image_urls else 0}")
        if attr.amap_image_urls and len(attr.amap_image_urls) > 0:
            print(f"  第一张图片: {attr.amap_image_urls[0][:80]}...")
        else:
            print("  图片: 无"

    print("\n调试完成！")

if __name__ == '__main__':
    quick_debug()
